package org.hackystat.devcathlon.ui.page.profile.browse;

import java.util.Arrays;
import java.util.List;

import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Panel;

/**
 * Alphabet Index Panel for creating reusable alphabet links.
 * 
 * @author Anthony Du
 *
 */
public class AlphabetIndexPanel extends Panel {
  /** Support serialization. */
  private static final long serialVersionUID = 1L;
  /** Alphabet Letters. */
  private static final String[] ALPHABETS = 
  { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S",
    "T", "U", "V", "W", "X", "Y", "Z"};
  private final List<String> ALPHALIST = Arrays.asList(ALPHABETS);
  
  /**
   * Constructs an Alphabet Index Panel.
   * @param id component id
   */
  public AlphabetIndexPanel(String id) {
    super(id);
    ListView lv = new ListView("alphabets", ALPHALIST) {
      /** Support serialization. */
      private static final long serialVersionUID = 1L;

      @Override
      protected void populateItem(ListItem item) {
        BookmarkablePageLink link = new BookmarkablePageLink("link", ProfileBrowsePage.class); 
        link.add(new Label("caption", item.getModel())); 
        item.add(link);
      }
    };
    add(lv);
  }
}
